{% extends "base.html" %}
{% load common_filters %}
{% load static %}
{% load crispy_forms_tags %}

{% block title %}
Teacher Dashboard | {{ block.super }}
{% endblock title %}

{% block stylesheets %}
{{ block.super }}
<link href="{% static "laioffer/css/dashboard.css" %}" rel="stylesheet">
{% endblock stylesheets %}

{% block content %}
{% include "_student_sidebar.html" %}

<section id="main-content">
    <section class="wrapper">
        {%  include "_message.html" %}
        <!-- upload new resume panel -->
        <section class="panel">
            <div class="panel-heading">
                Upload New Resume
            </div>
            <div class="panel-body">
                <form method="post" enctype="multipart/form-data">
                    {% csrf_token %}
                    {{ resume_form|crispy }}
                    <input type="hidden" name="create_resume" value="true">
                    <div class="fatherrelative1">
                        <input class="upload3" type="submit">
                    </div>
                </form>
            </div>
        <hr>
        </section>

        {% for job in resume_ctx.ordered_jobs %}

        <section class="panel">
            <div class="panel-heading">
                {{ job.desc }}
            </div>
            <div class="panel-body">

                {% for version in job.versions %}
                <div class="panel-group">
                    <div class="panel-info">
                        <a href="{{ version.url }}" class="inlineblockset">
                            <h4>version #{{ version.id }}: <span class="glyphicon glyphicon-download-alt"></span>
                            </h4>

                        </a>
                    </div>
                    <!-- show comments -->
                    {% if version.has_comment %}
                    {% if version.comment_num > 1 %}
                    <div class="floatleft1">
                        <a data-toggle="collapse" data-target="#{{ job.desc }}-{{ version.id }}">
                            More
                        </a>
                    </div>
                    {% endif %}
                    <!-- show last comment -->
                    <div class="commentshow2">
                        {% with last_comment=version.comments.0 %}
                        {{ last_comment.text }}
                        <br>
                        <div class="floatleft1">
                            <div class="username">{{ last_comment.author_fullname }}</div>
                            <div class="createdtime">{{ last_comment.time }}</div>
                        </div>
                        {% endwith %}
                        <hr style=" margin-top: 0;">
                    </div>
                    {% if version.comment_num > 1 %}
                    <div class="panel-group">
                    <div class="collapse commentshow2" id='{{ job.desc }}-{{ version.id }}'>
                        {% for comment in version.comments %}
                        {% if comment.collapsed %}
                        {{ comment.text }}
                        <br>
                        <div class="floatleft1">
                            <div class="username">{{ comment.author_fullname }}</div>
                            <div class="createdtime">{{ comment.time }}</div>
                        </div>
                        <hr style=" margin-top: 0;">
                        {% endif %}
                        {% endfor %}
                    </div>
                    </div>
                    {% endif %}
                    {% endif %}
                    <!-- add comment -->

                    {% if version.can_comment %}
                    <div>
                        <form method="post">
                            {% csrf_token %}
                            {{ comment_form|crispy }}
                            <input type="hidden" name="last_resume_pk" value="{{ version.pk }}">
                            <button type="submit">Add</button>

                        </form>
                    </div>
                    {% endif %}
                    <!-- upload new version -->
                    <div>
                        <br>
                        <h4>Upload New Resume: {{ job.desc }}</h4>
                        <br>
                        <form method="post" enctype="multipart/form-data">
                            {% csrf_token %}
                            <input type="hidden" name="update_resume" value="true">
                            <input type="file" name="resume">
                            <input type="hidden" name="desc" value="{{ job.desc }}">
                            <div class="fatherrelative1">
                                <input class="upload2" type="submit">
                            </div>
                        </form>
                    </div>
                </div>
                <hr>
                {% endfor %}
            </div>
        </section>
        {% endfor %}



    </section>
</section>


{% endblock content %}
